Set = {}
Set.mt = {}

function Set.new(t)
	local set = {}
	setmetatable(set,Set.mt)
	for _, l in ipairs(t) do
		set[l] = true
	end
	return set
end

function Set.union(a, b)
	local set = {}
	for l in pairs(a) do set[l] = true	end
	for l in pairs(b) do set[l] = true	end
	return set
end

function Set.intersection(a, b)
	local set = Set.new()
	for k in paires(a) do
		set[k] = b[k]
	end
	return set
end


function Set.tostring (set)
	local s = "{"
	local sep = ""
	for e in pairs(set) do
		s = s .. sep .. e
	sep = ", "
	end
	return s .. "}"
end

function Set.print (s)
	print(Set.tostring(s))
end



Set.mt.__add = Set.union

s1 = Set.new{10, 20, 30, 50}
s2 = Set.new{30, 1}
print(getmetatable(s1)) --> table: 00672B60
s3= s1 + s2
Set.print(s3)